import App from "./App";

// 引入 HiRouter
import hiRouter from "@/uni_modules/hi-router";

// #ifndef VUE3
import Vue from "vue";
import "./uni.promisify.adaptor";
Vue.config.productionTip = false;
App.mpType = "app";
const app = new Vue({
    ...App,
});
app.$mount();
// #endif

// #ifdef VUE3
import {
    createSSRApp
} from "vue";
export function createApp() {
    const app = createSSRApp(App);

    // 使用 HiRouter
    app.use(hiRouter, {
        // 前置路由拦截函数
        before: function(target, params, current) {
            console.log("hiRouter 前置路由拦截函数 ->", target)
            return true;
        },

        // 后置路由钩子函数
        after: function(current) {
            console.log("hiRouter 后置路由钩子函数 ->", current);
            uni.showModal({
                title: "提示",
                content: `进入到了${current?.style?.navigationBarTitleText}`,
            });
            // ... 跳转后的逻辑
        },
    });

    return {
        app,
    };
}
// #endif